<template>
  <div class="app-container">
    <tit></tit>
    <div class="template-form dis-flex">
      <div class="template-info-l template-info mr-20 ">
        <p class="h2">基本信息
          <span @click="edit">
            <i class="el-icon-edit"></i>
          </span>
        </p>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            子账号：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.username}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            手机号码：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.phone}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            身份证号码：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.userInfo.idCardNum}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            联系人：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.userInfo.contact}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            所在地区：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.userInfo.province}}{{formData.userMain.userInfo.city}}{{formData.userMain.userInfo.district}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            有效期：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.buyDateLength}}
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            当前状态：
          </div>
          <div class="formlist-desc flex-1">
            <div v-if="formData.userMain.isEnabled" class="Jstate Jstate-s">
              <span></span>已激活</div>
            <div v-else class="Jstate Jstate-f">
              <span></span>未激活</div>
          </div>
        </div>
        <div class="dis-flex formlist">
          <div class="formlist-tit">
            到期日期：
          </div>
          <div class="formlist-desc flex-1">
            {{formData.userMain.enableDate?formData.userMain.enableDate:'/'}}
          </div>
        </div>
      </div>
      <div class="flex-1 template-info-r template-info mr-20 ">
        <p class="h2">身份认证
          <span @click="edit">
            <i class="el-icon-edit"></i>
          </span>
        </p>
        <div class="formlist-l">
          <div class="formlist-tit mb-20">
            身份证照片：
          </div>
          <div class="formlist-desc border-btttom-1">
            <div class="formlist-desc-img mr-20">
              <div class="formlist-desc-img-hd">
                <img :src="formData.resDomain+formData.userMain.userInfo.idCardFrontUrl" @click.stop="bigImgShow($event)"
                />
              </div>
              <p>正面</p>
            </div>
            <div class="formlist-desc-img">
              <div class="formlist-desc-img-hd">
                <img :src="formData.resDomain+formData.userMain.userInfo.idCardBackUrl" @click.stop="bigImgShow($event)"/>
              </div>
              <p>反面</p>
            </div>
          </div>
          <div class="formlist border-btttom-none">
            <div class="formlist-tit mb-20">
              详细地址：
            </div>
            <div class="formlist-desc txt-l">
              {{formData.userMain.userInfo.address}}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="img-show-mask" id="img-show-mask" v-show="maskBtn" @click="closeBigImg"><img :src="bigImgSrc" class="bigImg" id="bigImg" /></div>
  </div>
</template>
<script>
  import tit from '@/components/Htitle'
  export default {
    data() {
      return {
        id: '',
        formData: null,
        maskBtn:false,
        bigImgSrc:''
      }
    },
    components: {
      tit
    },
    created() {
      let self = this
      let id = self.$route.query.id
      self.id = id
      self.getAccount(id)
    },
    methods: {
      getAccount(id) {
        let self = this
        self.$store.dispatch('getAccount', { id: id }).then(res => {
          if (res.success) {
            self.formData = res.data
          } else {
            self.$message({
              message: res.message,
              type: 'error'
            })
          }
        })
      },
      bigImgShow: function(e) { //打开图片预览
				this.bigImgSrc = e.target.src;
				this.maskBtn = true;
				this.$nextTick(function() {
					var imgShowMask = document.getElementById('img-show-mask');
					var img = document.getElementById('bigImg');
					var w = document.documentElement.clientWidth || document.body.clientWidth;
					var h = document.documentElement.clientHeight || document.body.clientHeight;
					var offsetY=window.pageYOffset;
					var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
						imgShowMask.style.height=scrollHeight+'px';
						img.style.left=(w/2-250)+'px';
						img.style.top=(h/2-70+offsetY)+'px';
				});
 
			},
			closeBigImg: function() { //关闭图片预览
				this.maskBtn = false;
      },
      edit(){
        console.log(2222222222)
        this.$router.push({
          name:'Table',query:{id:this.id}
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .template-form {
    background: none;
  }

  .template-info {
    background: #ffffff;
    padding: 20px;
    p {
      font-size: 14px;
      color: rgba(155, 155, 155, 1);
      line-height: 20px;
      margin-bottom: 30px;
    }
  }

  .formlist {
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(230, 230, 230, 1);
    .formlist-desc {
      text-align: right;
      font-size: 14px;
      color: rgba(74, 74, 74, 1);
      line-height: 20px;
    }
  }

  .formlist-tit {
    font-size: 14px;
    color: rgba(155, 155, 155, 1);
    line-height: 20px;
  }

  .template-info-l {
    width: 360px;
  }

  .Jstate span {
    display: inline-block;
    height: 6px;
    width: 6px;
    margin-right: 10px;
    border-radius: 100%;
    background-color: rgba(26, 169, 123, 1);
    vertical-align: middle;
  }

  .Jstate-f span {
    background: rgba(155, 155, 155, 1);
  }

  .Jstate {
    position: relative;
    padding-left: 12px;
  }

  .formlist-l {
    padding-left: 60px;
    padding-right: 60px;
  }

  .formlist-desc-img {
    display: inline-block;
    vertical-align: middle;
    width: 190px;
    margin-bottom: 66px;
    .formlist-desc-img-hd {
      width: 100%;
      height: 130px;
      background: rgba(230, 230, 230, 1);
      border-radius: 5px;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
    p {
      text-align: center;
      font-size: 14px;
      color: rgba(74, 74, 74, 1);
      line-height: 20px;
      margin-top: 8px;
    }
  }

  .border-btttom-1 {
    border-bottom: 1px solid rgba(230, 230, 230, 1);
  }

  .border-btttom-none {
    border-bottom: 0;
  }

  .txt-l {
    text-align: left !important;
  }

  .h2 {
    span {
      display: inline-block;
      width: 20px;
      height: 20px;
      border-radius: 100%;
      background: rgba(238, 242, 243, 1);
      text-align: center;
      cursor: pointer;
      float: right;
      .el-icon-edit {
        font-size: 12px;
        line-height: 20px;
      }
    }
  }
  
.img-show-mask {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, .5);
}
 
.img-show-mask .bigImg {
    width: 500px;
    height: 280px;
    position: absolute;
    z-index: 3100;
    top: 0;
    left: 0;
    margin: auto;
}
</style>